<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="utf-8">
  <title>地图单击拾取经纬度</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <style>
    body,
    html,
    #container {
      overflow: hidden;
      width: 100%;
      height: 100%;
      margin: 0;
      font-family: "微软雅黑";
    }
  </style>
  <script src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=Scb3oUk3aT2I0nl5hFBgxuNGOrd9aanr"></script>
</head>

<body>
  <div id="container"></div>
</body>

</html>
<script>
  var map = new BMapGL.Map("container");
  var point = new BMapGL.Point(116.404, 39.915);
  var marker = null
  var getData = new BMapGL.Geocoder();
  map.centerAndZoom(point, 15);
  map.enableScrollWheelZoom(true);
  map.addEventListener('click', function (e) {
    map.removeOverlay(marker);
    point = new BMapGL.Point(e.latlng.lng, e.latlng.lat)
    marker = new BMapGL.Marker(point);
    map.panTo(point)
    map.addOverlay(marker);
    getData.getLocation(point, function (rs) {
      var address = rs.address;
      var infoWindow1 = new BMapGL.InfoWindow(address);
      map.openInfoWindow(infoWindow1, point);
    })
  });
</script>